package com.snap.awesomeserial.base;

import android.view.View;

public abstract class OnDebounceClickListener implements View.OnClickListener {

    private static boolean enabled = true;

    private static final Runnable ENABLE_AGAIN = () -> {
        enabled = true;
    };

    @Override
    public final void onClick(View v) {
        if (enabled) {
            enabled = false;
            v.postDelayed(ENABLE_AGAIN, 500);
            doClick(v);
        }
    }

    public abstract void doClick(View v);

}